# Contributor: Jonas Marklen <txc@txc.se>
# Contributor: H <agathos5@gmail.com>
# Maintainer: Hoang Nguyen <folliekazetani@protonmail.com>
pkgname=megatools
pkgver=1.11.1.20230212
pkgrel=1
pkgdesc="Collection of programs for accessing Mega.nz service"
url="https://megatools.megous.com"
arch="all"
license="GPL-2.0-only"
makedepends="
	asciidoc
	curl-dev
	docbook2x
	glib-dev
	gmp-dev
	meson
	openssl-dev
	"
subpackages="$pkgname-doc $pkgname-bash-completion"
source="https://megatools.megous.com/builds/megatools-$pkgver.tar.gz"

build() {
	abuild-meson \
		-Db_lto=true \
		. output
	meson compile -C output
}

check() {
	meson test --no-rebuild --print-errorlogs -C output
}

package() {
	DESTDIR="$pkgdir" meson install --no-rebuild -C output

	install -Dm644 contrib/bash-completion/megatools \
		"$pkgdir"/usr/share/bash-completion/completions/megatools

	for bin in megacopy megadf megadl megaget megals megamkdir megaput megareg megarm; do
		ln -s megatools "$pkgdir"/usr/share/bash-completion/completions/$bin
	done
}

sha512sums="
8d96533c6ae117f38e095b16f4c3241a9170397174befaff9caf81b598addbe60c89c05d29b20efead462a8f263f799107653cab1ad429ab2ba2fe0dc4fbbb39  megatools-1.11.1.20230212.tar.gz
"
